#ifndef C3POM_PLUGIN_MANAGER_H
#define C3POM_PLUGIN_MANAGER_H
#include<string>
#include<map>
#include<omp.h>
#include"plugin.h"
#include"service.h"
#include"application.h"
#include"command.h"
#include"log.h"

namespace c3pom
{
	class PluginMonitor
	{
		private:
			std::string loc;
			std::string statu;
			Plugin* plugin;
			int threadnum;
			omp_lock_t lock;
		private:
			PluginMonitor();
			friend class PluginManager;
	};
	class PluginManager:public Service
	{
		private:
			Log* log;
			omp_lock_t pllock;
			std::map<std::string,PluginMonitor*> plugins;
			friend class Lspl;
			friend class LoadPlugin;
			class Lspl:public Command
		{
			public:
				std::string name();
				std::string desc();
				int exec(std::vector<std::string>);
		};
			class LoadPlugin:public Command
		{
			public:
				std::string name();
				std::string desc();
				int exec(std::vector<std::string>);
		};
			class RunPlugin:public Command
		{
			public:
				std::string name();
				std::string desc();
				int exec(std::vector<std::string>);
		};
		public:
			static PluginManager* getInstance();
			PluginManager();
			int loadPlugin(std::string);
			int runPlugin(std::vector<std::string>);

			//服务相关
			std::string name();
			std::string desc();
			void run();
	};
}
#endif
